import Vue from 'vue'
import Router from 'vue-router'
import ShoppingMall from '@/components/pages/ShoppingMall';
import Register from '@/components/pages/Register'
import Login from '@/components/pages/Login'
import Goods from '@/components/pages/Goods'
import CategoryList from '@/components/pages/CategoryList'
import Cart from '@/components/pages/Cart'
import Vip from '@/components/pages/Vip'
import Main from '@/components/pages/Main'


Vue.use(Router)

export default new Router({
  routes: [
    { 
      path:'/', component:Main, meta:{keepAlive:false},
      children: [
        { path:'/', name:'home', component:ShoppingMall, meta:{keepAlive:false} },
        { path:'/goods', name:'Goods', component:Goods, meta:{keepAlive:true} },
        { path:'/gategoryList', name:'CategoryList', component:CategoryList, meta:{keepAlive:false} },
        { path:'/cart', name:'Cart', component:Cart, meta:{keepAlive:false} },
        { path:'/vip', name:'Vip', component:Vip, meta:{keepAlive:false} },
      ]
    },
    { path:'/register', name:'Register', component:Register, meta:{keepAlive:false} },
    { path:'/login', name:'Login', component:Login, meta:{keepAlive:false} },
  ],
  scrollBehavior (to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return { x: 0, y: 0 }
    }
  }
})
